package com.mls.fivedistrict.controller.backend;

import com.mls.fivedistrict.common.ServiceResponse;
import com.mls.fivedistrict.controller.BaseController;
import com.mls.fivedistrict.pojo.Task;
import com.mls.fivedistrict.server.TaskService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * Created by nanji on 2018/3/21.
 */
@RestController
@RequestMapping("/api/manager")
public class TaskController extends BaseController {
    @Resource(name = "taskService")
    TaskService taskService;

    @GetMapping("/v1/taskCategroys")
    public ServiceResponse getCategory(){
        return taskService.getCategoryList();
    }
    @GetMapping("/v1/task/{taskId}")
    public ServiceResponse getTask(@PathVariable("taskId") Long id) {
        return taskService.getTask(id);
    }
    @DeleteMapping("/v1/task/{taskId}")
    public ServiceResponse deleteTask(@PathVariable("taskId") Long id) {
        return taskService.deleteTask(id);
    }

    @PostMapping("/v1/task")
    public ServiceResponse addTask(@RequestBody Task task) {
        return taskService.addTask(task);
    }

    @PutMapping("/v1/task/{taskId}")
    public ServiceResponse EditTask(@RequestBody Task task, @PathVariable("taskId") Long taskId) {
        return taskService.editTask(task, taskId);
    }

    @RequestMapping("/v1/tasks")
    public ServiceResponse getTaskList() {
        return taskService.getTaskList(getPageFilter());
    }
    @RequestMapping("/v1/task/all")
    public ServiceResponse getAllTask() {
        return taskService.getAllTask();
    }


}
